﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using TrainingCenterSystem;
using TrainingCenterSystem.UserManagement;

namespace TrainingCenterSystem.TestManagement
{
    public enum TestType
    {
        FreeText,
        MultipleChoice,
        Mixed
    }

    public enum TestLevel
    {
        Basic,
        Extended
    }

    public enum TestDirection
    {
        BaseToTranslation,
        TranslationToBase,
        Mixed
    }

    public class VocabularyTraining
    {
        #region protected members
        protected string _id;
        protected string _name;
        protected string _description;        
        protected byte _numberOfQuestions;
        protected List<TestQuestion> _testQuestions;        
        protected User _creator;
        protected TestType _testType;
        protected TestLevel _testLevel;
        protected TestDirection _testDirection;
        protected ArrayList _selectedSources;

        #endregion

        #region setters and getters
        /// <summary>
        /// Gets or sets the id.
        /// </summary>
        public string TestID
        {
            get { return _id; }
            set { _id = value; }
        }

        /// <summary>
        /// Gets or sets the name of the test.
        /// </summary>
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        /// <summary>
        /// Gets or sets the description of the test.
        /// </summary>
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        

        /// <summary>
        /// Gets or sets the amount of questions of the test.
        /// </summary>
        public byte NumberOfQuestions
        {
            get { return _numberOfQuestions; }
            set { _numberOfQuestions = value; }
        }

        
        /// <summary>
        /// Gets or sets the creator of the test.
        /// </summary>
        public User Creator
        {
            get { return _creator; }
            set { _creator = value; }
        }

        /// <summary>
        /// Gets the questions of the test.
        /// </summary>
        public List<TestQuestion> TestQuestions
        {
            get { return _testQuestions; }
        }

        /// <summary>
        /// Gets or sets the type of the test.
        /// </summary>
        public TestType TestType
        {
            get { return _testType; }
            set { _testType = value; }
        }

        /// <summary>
        /// Gets or sets the level of the test.
        /// </summary>
        public TestLevel TestLevel
        {
            get { return _testLevel; }
            set { _testLevel = value; }
        }

        /// <summary>
        /// Gets or sets the sources of the test
        /// </summary>
        public ArrayList SelectedSources
        {
            get { return _selectedSources; }
            set { _selectedSources = value; }
        }

        public TestDirection TestDirection
        {
            get { return _testDirection; }
            set { _testDirection = value; }
        }
        #endregion

        #region constructor(s)
        public VocabularyTraining()
        {
        }
        /// <summary>
        /// Creates a vocabulary training object
        /// </summary>
        /// <param name="name">the name of the training</param>
        /// <param name="description">the description of the training</param>
        /// <param name="noOfQuestions">the number of questions</param>
        /// <param name="level">the level of the training</param>
        /// <param name="type">the type of the training</param>
        /// <param name="selSources">the selected sources</param>
        public VocabularyTraining(string name, string description, byte noOfQuestions, TestLevel level, TestType type, ArrayList selSources, TestDirection testDirection)
        {
            _name = name;
            _description = description;
            _numberOfQuestions = noOfQuestions;
            //this.setTestLevel(level);
            //this.setTestType(type);  
            _testLevel = level;
            _testType = type;
            _testDirection = testDirection;
            _selectedSources = selSources;
            _testQuestions=new List<TestQuestion>();
        }

        public VocabularyTraining(string name, string description, byte noOfQuestions, int level, int type)
        {
            _name = name;
            _description = description;
            _numberOfQuestions = noOfQuestions;
            this.setTestLevel(level);
            this.setTestType(type);            
            _testQuestions = new List<TestQuestion>();

        }
        #endregion

        #region methods
        protected void setTestLevel(int testLevel)
        {
            if (testLevel == 0)
                _testLevel = TestLevel.Basic;
            else
                _testLevel = TestLevel.Extended;
        }

        protected void setTestType(int testType)
        {
            if (testType == 0)
                _testType = TestType.FreeText;
            else if (testType == 1)
                _testType = TestType.MultipleChoice;
            else
                _testType = TestType.Mixed;
        }

        /*protected void refreshQuestions()
        {
            for (int i=0;i<_testQuestions.Count;i++)
                _testQuestions[i].
        }*/
        #endregion
    }
}
